/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

jQuery(document).ready(
    function(){
        var open = false;
        $(".incomeFigures").live("dblclick", function(){
            if(!open){
                open = true;
                $(this).html("<input class=\"incomeInput\" id=\""+$(this).attr('id')+"\" type=\"text\" value =\""+$(this).text()+"\"/>");
                $(".incomeInput").focus();
            }
            else{
              $('.incomeInput').blur();
              open = false;
            }

        });

        $(".incomeInput").livequery(function(){
            $(this).blur(function(){
                open = false;
                var href = $(".urlUpdateIncome").attr("href");
                var id = $("#projectId").val();
                var type = $(this).attr('id');
                var val = $(this).val();
                 $(this).parent().text(val);
                 $.ajax({
                        url: href,
                        data: "id="+id+"&typeOfIncome="+type+"&figure="+val,
                        cache: false,
                        async: true,
                        success: function(html){}
                 });
            })
        });
    }
);

